﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Platform.Migrations
{
    /// <inheritdoc />
    public partial class add_table_MsgSendRec : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "MSG_BIZ_TYPE",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    MSG_BIZ_TYPE_CODG = table.Column<string>(type: "text", nullable: false),
                    MSG_BIZ_TYPE_NAME = table.Column<string>(type: "text", nullable: false),
                    SRTNO = table.Column<int>(type: "integer", nullable: false),
                    DEFAULT_FLAG = table.Column<bool>(type: "boolean", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MSG_BIZ_TYPE", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "MSG_SEND_REC",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    MsgBizTypeId = table.Column<Guid>(type: "uuid", nullable: false),
                    MSG_CONT = table.Column<string>(type: "text", nullable: false),
                    MSG_SEND_USERID = table.Column<Guid>(type: "uuid", nullable: true),
                    MSG_SEND_USERNAME = table.Column<string>(type: "text", nullable: true),
                    MSG_SEND_DEPTID = table.Column<Guid>(type: "uuid", nullable: true),
                    MSG_SEND_DEPTNAME = table.Column<string>(type: "text", nullable: true),
                    MSG_RECV_DEPTID = table.Column<string>(type: "text", nullable: true),
                    MSG_RECV_DEPTNAME = table.Column<string>(type: "text", nullable: true),
                    MSG_RECV_USERID = table.Column<Guid>(type: "uuid", nullable: true),
                    MSG_RECV_USERNAME = table.Column<string>(type: "text", nullable: true),
                    MSG_STATS = table.Column<int>(type: "integer", nullable: false),
                    MSG_LV = table.Column<int>(type: "integer", nullable: false),
                    BIZ_NO = table.Column<string>(type: "text", nullable: true),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MSG_SEND_REC", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MSG_SEND_REC_MSG_BIZ_TYPE_MsgBizTypeId",
                        column: x => x.MsgBizTypeId,
                        principalTable: "MSG_BIZ_TYPE",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "MSG_READ_REC",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    MsgSendRecId = table.Column<Guid>(type: "uuid", nullable: false),
                    MSG_RECV_USERID = table.Column<Guid>(type: "uuid", nullable: true),
                    MSG_RECV_USERNAME = table.Column<string>(type: "text", nullable: true),
                    MSG_RECV_TIME = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_MSG_READ_REC", x => x.Id);
                    table.ForeignKey(
                        name: "FK_MSG_READ_REC_MSG_SEND_REC_MsgSendRecId",
                        column: x => x.MsgSendRecId,
                        principalTable: "MSG_SEND_REC",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_MSG_READ_REC_MsgSendRecId",
                table: "MSG_READ_REC",
                column: "MsgSendRecId");

            migrationBuilder.CreateIndex(
                name: "IX_MSG_SEND_REC_MsgBizTypeId",
                table: "MSG_SEND_REC",
                column: "MsgBizTypeId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "MSG_READ_REC");

            migrationBuilder.DropTable(
                name: "MSG_SEND_REC");

            migrationBuilder.DropTable(
                name: "MSG_BIZ_TYPE");
        }
    }
}
